New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

datocms-structured-text-utils

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datocms-structured-text-utils

A set of Typescript types and helpers to work with DatoCMS Structured Text fields

  • 0.1.0-alpha.27
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created

What is datocms-structured-text-utils?

The datocms-structured-text-utils package provides utilities for working with DatoCMS's structured text format. It allows developers to parse, manipulate, and render structured text content in a flexible and efficient manner.

What are datocms-structured-text-utils's main functionalities?

Rendering Structured Text

This feature allows you to render structured text documents into HTML. The code sample demonstrates how to convert a simple structured text document into an HTML paragraph.

const { render } = require('datocms-structured-text-utils');

const document = {
  schema: 'dast',
  document: {
    type: 'root',
    children: [
      {
        type: 'paragraph',
        children: [{ type: 'span', value: 'Hello, world!' }]
      }
    ]
  }
};

const html = render(document);
console.log(html); // Outputs: <p>Hello, world!</p>

Transforming Structured Text

This feature allows you to transform structured text documents. The code sample shows how to transform the text content of a paragraph to uppercase.

const { transform } = require('datocms-structured-text-utils');

const document = {
  schema: 'dast',
  document: {
    type: 'root',
    children: [
      {
        type: 'paragraph',
        children: [{ type: 'span', value: 'Hello, world!' }]
      }
    ]
  }
};

const transformedDocument = transform(document, {
  paragraph: ({ children }) => ({
    type: 'paragraph',
    children: [{ type: 'span', value: children[0].value.toUpperCase() }]
  })
});

console.log(transformedDocument);

Other packages similar to datocms-structured-text-utils

Keywords

FAQs

Package last updated on 01 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc